/*
 * @author zzr
 * @date: 2025/05/11  20:17
 * @description: 引入 Callable 接口
 */
public class Demo15 {

    private static int sum = 0;

    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            int result = 0;
            for (int i = 0; i < 1000; i++) {
                result += i;
            }
            sum = result;
        });
        // 希望关注线程中的返回值 这样操作不优雅
        t.start();
        t.join();
        System.out.println("sum = " + sum);
    }
}
